home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Diamond Collection
/
The Diamond Collection (Software Vault)(Digital Impact).ISO
/
cdr13
/
txt_srch.zip
/
TXT_SRCH.BAS
next >
Wrap
BASIC Source File
|
1995-01-17
|
5KB
|
83 lines
CLS ' This program requires QUICK BASIC 4.5 to run the source code or compile.
' This program is freeware and may be used by anyone freely.
' written 1/15/95 by Van Lincoln as a programming example.
PRINT "This program finds a specific string(s) in the text database"
PRINT "and then shows you the database entry information, optionally"
PRINT "producing a printed copy of the information on your printer."
PRINT "Make sure that your PRINTER is ON and ready to print !"
PRINT "Press the <Esc> key anytime to halt processing and return to main program"
'----------------------------------------------------
80 LOCATE 7, 1: INPUT "ENTER THE DATABASE FILE NAME TO SEARCH :"; IFILE$ ' input file name
84 ON ERROR GOTO 850
90 OPEN IFILE$ FOR INPUT AS #1
OPEN IFILE$ FOR INPUT AS #2
100 LOCATE 9, 1
104 INPUT "Enter the '1st String of characters' that you wish to find : ", SS1$ ' Search string
108 INPUT "do you want to enter a '2nd' string Y/N "; yn$: yn$ = LCASE$(yn$)
110 IF yn$ <> "y" THEN 118
111 INPUT "(A)nd / (O)r for the 1st and 2nd strings (A/O) "; ao$: ao$ = LCASE$(ao$)
112 INPUT "Enter the '2nd String of characters' that you wish to find : ", ss2$ ' Search string
116 ss2$ = LCASE$(ss2$) 'convert to lower case if uppercase
118 SS1$ = LCASE$(SS1$) 'convert to lower case if uppercase
120 LOCATE 13, 1
130 INPUT "Output to (S)creen or (P)rinter or (B)oth? (S,P,B) : ", TO.PRINT$
135 TO.PRINT$ = LCASE$(TO.PRINT$) ' convert to lowercase if uppercase
VIEW PRINT 15 TO 25
140 IF TO.PRINT$ = "s" THEN CRT% = -1: GOTO 210
150 IF TO.PRINT$ = "p" THEN PRT% = -1: GOTO 170
160 CRT% = -1: PRT% = -1
165 '------------------------------------------------------------------------
170 LPRINT "THIS LIST WAS PRODUCED ON "; DATE$; " AT "; TIME$; " and has found"
180 LPRINT "the selected strings in the following text database entries..."
190 LPRINT CHR$(15) + CHR$(27) + CHR$(48);
195 WIDTH LPRINT 132
200 '---------------------------------------------------------------
210 IF EOF(1) THEN 450
220 LINE INPUT #1, LIN$ ' input a line of the database
221 nLIN$ = LIN$ ' preserve original line case
222 LIN$ = LCASE$(LIN$) ' make data lowercase
225 GOSUB 900 ' Was Esc key pressed to exit?
230 ICOUNT! = ICOUNT! + 1 ' Count lines incoming
240 GOSUB 510 ' Show operation with line number
250 fs1% = INSTR(LIN$, SS1$) ' Found String 1?
251 IF yn$ <> "y" THEN IF fs1% < 1 GOTO 440 ELSE 270 ' no=only 1 string
252 fs2% = INSTR(LIN$, ss2$) ' Found String 2?
254 IF ao$ = "a" THEN IF fs1% > 0 AND fs2% > 0 THEN GOTO 270 ELSE 440
258 IF ao$ = "o" THEN IF fs1% > 0 OR fs2% > 0 THEN GOTO 270 ELSE 440
270 IF PRT% <> 0 THEN LPRINT ICOUNT!; " "; nLIN$
280 IF slow% = 1 THEN FOR I = 1 TO 10000: NEXT I
282 IF slow% = 2 THEN FOR I = 1 TO 20000: NEXT I
284 IF slow% = 3 THEN GOSUB 900: GOTO 284
288 IF CRT% <> 0 THEN PRINT ICOUNT!; " "; nLIN$
'
300 '----------------------------------------------------------------
440 IF NOT EOF(1) THEN 210
450 PRINT : GOTO 940
'---------------------------------------------------------------
' ---- Upper right corner line numbers to show operation. ----
'---------------------------------------------------------------
510 SROW% = CSRLIN: SCOL% = POS(0) ' Save old cursor position
LOCATE 16, 74: PRINT " "; : LOCATE 16, 74: PRINT ICOUNT;
LOCATE SROW%, SCOL%
RETURN
'---------In case of errors come here -------------
850 BEEP: PRINT "Error "; ERR; " at line "; ERL
IF ERL = 80 THEN PRINT "Input file not found : "; IFILE$
RESUME 890
890 SYSTEM
'------------ If escape key is pressed do this -----
900 ZZ$ = INKEY$
ZZ$ = LCASE$(ZZ$)
IF ZZ$ = "s" THEN GOSUB 1100
920 IF ZZ$ <> CHR$(27) THEN RETURN ' Esc key falls through
940 IF PRT% <> 0 THEN LPRINT : LPRINT CHR$(12) ' Final form feed
PRINT : PRINT "Finished search for "; SS1$; " "; ss2$; " in "; IFILE$
CLOSE
SYSTEM
'------------ If "S" PRESSED THEN SLOW -------------
1100 IF slow% = 0 THEN slow% = 1: RETURN
IF slow% = 1 THEN slow% = 2: RETURN
IF slow% = 2 THEN slow% = 3: RETURN
IF slow% = 3 THEN slow% = 0: RETURN